package com.dzzw.Servlet.UserServlet;


import com.dzzw.Dao.UserDao;
import com.dzzw.Model.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;

@WebServlet("/View/UserLoginServlet")
public class UserLoginServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
    public UserLoginServlet() {
        super();
    }
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        String user_actnumber = request.getParameter("user_actnumber");
        String user_password = request.getParameter("user_password");
        List<User> list = UserDao.UserLogin(user_actnumber,user_password);
        HttpSession session = request.getSession();
        session.setAttribute("UserLogin", list);//传值
        request.getRequestDispatcher("/View/User.jsp").forward(request, response);
        System.out.println("用户登录成功！");
    }
}